﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class FullDispinterfaceDefinitionElement : DispinterfaceDefinitionElement
    {
        private ConstExpressionElement guid;
        private List<ISectionElementElement> elements;

        public ConstExpressionElement Guid { get { return guid; } set { guid = value; } }
        public List<ISectionElementElement> Elements { get { return elements; } set { elements = value; } }

        public FullDispinterfaceDefinitionElement(TokenInfo StartInfo, ConstExpressionElement Guid, List<ISectionElementElement> Elements, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            guid = Guid;
            elements = Elements;
        }

        public override string ToString()
        {
            return string.Format("dispinterface\r\n{0}{1}\r\nend", guid,
                ((elements != null) && (elements.Count > 0)) ? string.Format("\r\n{0}", Tabulate(elements.Join("\r\n"))) : string.Empty);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return guid;
            foreach (ISectionElementElement element in elements)
                yield return element;
        }
    }
}
